<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改成本结算')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<style>
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-settlement-edit">
        <input id="id" name="id" type="hidden" th:value="${settlement.id}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">编号：</label>
            <div class="col-sm-8">
                <input type="hidden" id="billNo" th:value="${settlement.billNo}"/>
                <input class="form-control" type="text" name="billNo" placeholder="请输入编号"
                       th:value="${settlement.billNo}" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">项目名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="proName" placeholder="请输入项目名称" onchange="createNumber()"
                       th:value="${settlement.proName}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">工程公司：</label>
            <div class="col-sm-8">
                <input type="hidden" id="compName" th:value="${settlement.compName}"/>
                <select name="compName" th:with="compName=${@dict.getType('company')}" onchange="createNumber()"
                        class="form-control">
                    <option value="">请选择</option>
                    <option th:each="compName : ${compName}" th:text="${compName.dictLabel}"
                            th:value="${compName.dictLabel}" th:title="${compName.dictValue}"
                            th:selected="${compName.dictLabel==settlement.compName}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">商务经理：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="businessManager" placeholder="请输入商务经理"
                       th:value="${settlement.businessManager}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">审核内容：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="auditContent" placeholder="请输入审核内容"
                       th:value="${settlement.auditContent}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">分包班组信息：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="teamInfo" placeholder="请输入分包班组信息"
                       th:value="${settlement.teamInfo}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">申请金额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="applyMoney" placeholder="请输入申请金额"
                       th:value="${settlement.applyMoney}">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
    var prefix = ctx + "costSettlement";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-person-edit").serializeArray();
            $.operate.save(prefix + "/edit", data);
        }
    }

    function createNumber() {
        var compTitle = $("select[name='compName'] option:selected").attr("title");
        var compName = $("select[name='compName'] option:selected").val();
        var proName = $("input[name='proName']").val();
        if (typeof(compName) != "undefined" && compName != '' && proName != '') {
            $.ajax({
                url: prefix + '/createNumber',
                data: {
                    compTitle: compTitle,
                    compName: compName,
                    proName: proName,
                },
                type: 'POST',
                success: function (data) {
                    if ($("#compName").val() != compName) {
                        $("input[name='billNo']").val(data);
                    } else {
                        $("input[name='billNo']").val($("#billNo").val());
                    }
                }
            });
        } else {
            $("input[name='billNo']").val("");
        }
    }

</script>
</body>
</html>